<?php
namespace app\controller;
use \think\facade\Db;
use app\BaseController;

class Index extends BaseController
{
    public function index()
    {
//        $carsdatas=$this->request->param('carsdata');
//        $carsdata=json_decode($carsdatas,true);
//        foreach ($carsdata as $k=>$v){
//            echo  $v['name'];
//        }
//        echo   GetRandInt(20);

        //我测试下jenkins

        $data=[
            'uid'=>1,
            'timestamp'=>'1649225277',
            'nonce'=>'49502061965563728355',

         ];
        $api_salt='F6Z7z5POhE';

        sort($data,SORT_STRING);
        $paramsRes= implode($data);
         // key进行排序
        $signRes = md5($paramsRes.$api_salt);
        echo $signRes;


        $res = [
            ['id' => 1, 'start_time' => '2021-1-1', 'end_time' => '2021-1-1'],
            ['id' => 2, 'start_time' => '2021-1-1', 'end_time' => '2021-1-1'],

            ['start_time' => '2021-1-1', 'end_time' => '2021-1-1']
        ];
        echo json_encode($res);


    }

    public function hello($name = 'ThinkPHP6')
    {
        return 'hello,' . $name;
    }

    public function  indexdata()
    {
        $data=[
            'partner_name'=>'封丘县'
        ];
        returnSuccess(200,'获取成功',$data);
    }
    
        public function test1()
    {

        $data = Db::table('xl_warehouse')->select()->toArray();
        foreach ($data as $key=>$value){
            if(empty($value['bd_gps_longitude'])){
                $gpsInfo = baidutogps($value['longitude'],$value['dimension']);
                if($gpsInfo!=400){
                    Db::table('xl_warehouse')->where('id',$value['id'])->update(['bd_gps_longitude'=>$gpsInfo[0]['x'],'bd_gps_dimension'=>$gpsInfo[0]['y']]);
                }
            }
        }
    }
    
    
    public function test1226()
    {
        $data = Db::table('xl_normal_task')->where('real_time_consume', '=', 0)->limit(500)->select()->toArray();
        foreach ($data as $k => $v) {
            if ($v['task_type'] == 1) {
                $sliceTime = $v['date'] . ' 10:30:00';
            } else {
                $sliceTime = $v['date'] . ' 15:30:00';
            }
            Db::table('xl_normal_task')->where('id', $v['id'])->update(['real_time_consume' => 1, 'slice_time' => $sliceTime]);
        }
    }


}
